/*
 * Copyright 2009 Aleksandar Seovic
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.seovic.validation;


import com.seovic.validation.actions.ErrorMessageAction;


/**
 * @author ic  2009.06.08
 */
public final class HelperClasses {

    private HelperClasses() {}

    public static abstract class BaseTestValidator extends BaseValidator {
        private boolean wasCalled;

        public boolean wasCalled() {
            return wasCalled;
        }

        @Override
        public boolean validate(Object validationContext, ValidationErrors errors) {
            wasCalled = true;
            return super.validate(validationContext, errors);
        }
    }

    public static class TrueValidator extends BaseTestValidator {

        protected boolean validate(Object objectToValidate) {
            return true;
        }
    }


    public static class FalseValidator extends BaseTestValidator {

        public FalseValidator() {
            getActions().add(new ErrorMessageAction("error", "errors"));
        }

        protected boolean validate(Object objectToValidate) {
            return false;
        }
    }
}
